package com.cgx.entity.message;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * @author chenguanxin
 * @date 2021-05-25 21:14
 */
@Data
@Document(collection = "message")
public class Message {
    @Id
    @Field("id")
    private String id;
    @Field("message_id")
    private String messageId;
    @Field("session_id")
    private String sessionId;
    @Field("from_user_id")
    private String fromUserId;
    @Field("type")
    private Integer type;
    @Field("content")
    private String content;
    @Field("create_by")
    private String createBy;
    @Field("create_time")
    private Date createTime = new Date();
    @Field("update_by")
    private String updateBy;
    @Field("update_time")
    private Date updateTime;
    @Field("is_delete")
    private Integer isDelete = 0;


    public static Message getMessage(String userId) {
        Message message = new Message();
        message.setFromUserId(userId);
        message.setCreateBy(userId);
        message.setCreateTime(new Date());
        message.setUpdateBy(userId);
        message.setUpdateTime(new Date());
        message.setIsDelete(0);
        return message;
    }
}
